package com.freestyle.jmssample.api.pojo;

import lombok.ToString;

import java.io.Serializable;

/**
 * Created by rocklee on 2022/1/5 15:42
 */
@ToString
public class JSONData <T>implements Serializable {
  private static final long serialVersionUID = -7719174847256301044L;
  public final static int ERROR_CODE_SUCCESS=0;
  public int errCode;
  public T result;
  public String message;
  public JSONData(){
    errCode=ERROR_CODE_SUCCESS;
    result=null;
    message="";
  }
  public static JSONData<Object> JSONDataFromException( Exception pvException){
    JSONData<Object> ret=new JSONData<Object>();
    ret.errCode=-1;
    ret.result=null;
    ret.message=pvException.getMessage();
    return ret;
  }

  public static <V> JSONData JSONDataFromResult(V pvResult){
    JSONData<V> lvRet=new JSONData<V>();
    lvRet.result=pvResult;
    return lvRet;
  }
  public JSONData(String pvExceptionMsg){
    errCode=-1;
    result=null;
    message=pvExceptionMsg;
  }
}
